package com.kly.user.db.dao.impl;
import com.fqgj.common.base.AbstractBaseMapper;
import com.fqgj.common.utils.CollectionUtils;
import com.google.common.collect.Maps;
import com.kly.user.db.dao.UserAppflyersMappingDao;
import com.kly.user.db.entity.UserAppflyersMappingEntity;
import org.springframework.stereotype.Repository;

import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
* User: linqu
* Date: 2023-07-29
* Time: 17:26:01.574
*/

@Repository
public class UserAppflyersMappingDaoImpl extends AbstractBaseMapper<UserAppflyersMappingEntity> implements UserAppflyersMappingDao {

    @Override
    public UserAppflyersMappingEntity getUserAppflyersMappingEntities(String userCode) {
        final HashMap<String, Object> params = Maps.newHashMap();
        params.put("userCode", userCode);
        final List<UserAppflyersMappingEntity> entities = this.getSqlSession().selectList(this.getStatement("selectByParams"), params);
        if (CollectionUtils.isEmpty(entities)) {
            return null;
        }
        return entities.get(0);
    }

    @Override
    public List<UserAppflyersMappingEntity> getAppflyerWithoutUsercode(String afid) {
        return this.getSqlSession().selectList(this.getStatement("getAppflyerWithoutUsercode"), afid);
    }
    @Override
    public UserAppflyersMappingEntity getAppflyerByAfid(String afid) {
        return this.getSqlSession().selectOne(this.getStatement("getAppflyerByAfid"), afid);
    }

    @Override
    public List<UserAppflyersMappingEntity> listDataNoneCompleteRecord(Date startDate, Date endDate) {
        Map<String, Object> params = Maps.newHashMap();
        params.put("startDate", startDate);
        params.put("endDate", endDate);
        return this.getSqlSession().selectList(this.getStatement("listDataNoneCompleteRecord"), params);
    }
}